<?php

namespace addon\lian\api\controller;

use addon\lian\model\api\LianMemberService;
use app\api\controller\BaseApi;

class Member extends BaseApi
{

    /**
     * 链动会员详情
     */
    public function info()
    {
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $info = (new LianMemberService())->getInfo();

        return $this->response($info);
    }

    /**
     * 链动会员详情
     */
    public function detail()
    {
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $info = (new LianMemberService())->getDetail();

        return $this->response($info);
    }

    /**
     * 获取链动会员账户信息
     */
    public function account()
    {
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $info = (new LianMemberService())->getAccount();

        return $this->response($info);
    }


    //获取会员奖励记录
    public function reward(){
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $page = $this->params['page'] ?? 1;
        $page_size = $this->params['page_size'] ?? PAGE_LIST_ROWS;

        $data = [
            ['create_time', []], 
        ];
        $info = (new LianMemberService())->getReward($data, $page, $page_size);

        return $this->response($info);
    }


    //获取会员直推下级
    public function recommendChild(){
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $info = (new LianMemberService())->getRecommendChild();

        return $this->response($info);
    }

    //获取会员团队
    public function team(){
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $info = (new LianMemberService())->getTeam();

        return $this->response($info);
    }

    //获取会员直推boss
    public function recommendBossChild(){
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $info = (new LianMemberService())->getRecommendBossChild();

        return $this->response($info);
    }


    //获取会员前2直推
    public function firstRecommend(){
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $info = (new LianMemberService())->getFirstRecommend();

        return $this->response($info);
    }


    //获取会员绩效任务期限
    public function taskLimitDays(){
        $token = $this->checkToken();
        if ($token[ 'code' ] < 0) return $this->response($token);

        $info = (new LianMemberService())->getTaskLimitDays();

        return $this->response($info);
    }

}
